﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using SGC.BL.PlanAuditoria;

namespace SGC.Web.ModuloCalidad.Mantenimientos.Informe_Auditoria
{
    public partial class ListarPlanAuditoria : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                BL_PlanAuditoria negocio = new BL_PlanAuditoria();
                dgdPlanAuditoria.DataSource = negocio.Listar(null, null);
                dgdPlanAuditoria.DataBind();
            }

        }

        private string ObtenerPlanAuditoria()
        {
            string strInforme = null;
            foreach (DataGridItem fila in dgdPlanAuditoria.Items)
            {
                CheckBox chk = (CheckBox)fila.FindControl("chk_item");
                if (chk.Checked)
                {
                    Label lbl = (Label)fila.FindControl("lblCodigoPlan");
                    strInforme = lbl.Text;
                    break;
                }
            }
            return strInforme;
        }


        protected void btnSeleccionar_Click(object sender, EventArgs e)
        {
            //OnClientClick="return jsClosePopup();"
            string plan = ObtenerPlanAuditoria();
            if (plan == null)
            {

            }
            else
            {
                Session["codPlanAud"] = plan;
                ScriptManager.RegisterStartupScript(this, this.GetType(), "Aprobar Informe Auditoria", "jsClosePopup('"+ plan +"');", true);
            }
        }




    }
}